package org.gitman.agentplatform.ui.simulation;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridLayout;

import javax.swing.ImageIcon;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JProgressBar;

import org.gitman.agentplatform.ui.MainFrame;
import org.gitman.agentplatform.ui.utils.ResourcesLoader;

public class MultirunDialog extends JDialog{
	private JProgressBar progressBar;
	private int size;
	private JLabel progressLabel;
	private String prefix = "Progress:\t";
		
	public MultirunDialog(int size, MainFrame mainFrame) {
		this.size = size;
		setLayout(new BorderLayout());		
		setTitle("Please wait...");
		progressBar = new JProgressBar(0, size);		
		progressBar.setPreferredSize(new Dimension(320, 25));
		add(progressBar, BorderLayout.SOUTH);
		
		setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);

		ImageIcon icon = ResourcesLoader.getInstance().getIcon("wait.png");
		JLabel label = new JLabel(icon);
		add(label,BorderLayout.WEST);
				
		JPanel centerPanel = new JPanel(new GridLayout(4, 1));
		centerPanel.add(new JLabel());
		centerPanel.add(new JLabel("Multirun of simulation"));
		progressLabel = new JLabel(prefix + "0/"+size);
		centerPanel.add(progressLabel);
		add(centerPanel, BorderLayout.CENTER);
				
		setAlwaysOnTop(true);
		setSize(320, 160);
		setLocationRelativeTo(mainFrame);
	}
	
	public void setProgress(int progress){
		progressBar.setValue(progress);
		progressLabel.setText(prefix + progress + "/" + size);
	}
}
